<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2022/4/13
  Time: 17:22
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="false" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<!DOCTYPE html>
<html lang="zh-cn">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
    <meta name="renderer" content="webkit">
    <title></title>

    <link rel="stylesheet" href="${pageContext.request.contextPath}/css/pintuer.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/css/admin.css">
    <script src="${pageContext.request.contextPath}/js/jquery.js"></script>
    <script src="${pageContext.request.contextPath}/js/pintuer.js"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/js/jquery-1.11.3.min.js"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/js/json2.js"></script>
</head>
<body>

<form method="post" action="">
    <div class="panel admin-panel">
        <div class="panel-head"><strong class="icon-reorder">用户管理</strong></div>

        <div class="padding border-bottom">
            <ul class="search">
                <li>
                    <button type="button" class="button border-green" id="checkall"><span class="icon-check"></span> 全选
                    </button>
                    <button type="submit" class="button border-red"><span class="icon-trash-o"></span> 批量删除</button>
                </li>
            </ul>
        </div>
        <table class="table table-hover text-center">
            <tr>
                <th width="120">请假条编号</th>
                <th>用户名</th>
                <th>开始时间</th>
                <th>结束时间</th>
                <th>事由</th>
                <th>创建时间</th>
                <th>操作</th>
            </tr>
            <c:forEach items="${applicationList}" var="applicationList" varStatus="a">
                <tr>
                    <td> ${applicationList.applicationId}</td>
                    <td> ${applicationList.userId}</td>
                    <td><fmt:formatDate value="${applicationList.applicationStartTime}" dateStyle="medium" pattern="yyyy-MM-dd HH:mm:ss" /></td>
                    <td> <fmt:formatDate value="${applicationList.applicationEndTime}" dateStyle="medium" pattern="yyyy-MM-dd HH:mm:ss" /></td>
                    <td> ${applicationList.applicationItem}</td>
                    <td><fmt:formatDate value="${applicationList.applicationCreateTime}" dateStyle="medium" pattern="yyyy-MM-dd HH:mm:ss" /> </td>
                    <td>
                            <div class="button-group"><a class="button border-blue" href="${pageContext.request.contextPath}/selectAppdetailById.do?applicationId=${applicationList.applicationId}"
                            ><span
                                    class="icon-trash-o"></span> 查看详情</a>
                            </div>

                        <div class="button-group" id="${applicationList.applicationId}"><a class="button border-blue" href="approveThisApplicationPage.do?approveId=${applicationList.approve.approveId}"><span
                                class="icon-trash-o"></span>审批</a>
                        </div>


                    </td>
                </tr>
            </c:forEach>
        </table>
        <div id="sss"></div>
    </div>
</form>
<script type="text/javascript">

    function commit(applicationId) {
        $.ajax({
            data: "applicationId=" + applicationId,
            type: "POST",
            dataType: 'json',
            url: "applicationCommit.do",
            success: function (data) {
                console.log(data);
                // $("#sss").empty();
                if (data == true) {
                    alert("提交成功");
                     location.reload();
                    // $("#sss").append('<a class="button border-blue" href="javascript:return false" ><span class="icon-trash-o"></span>已提交</a>');
                    // $("#select1").append('<option value=' + userId + '>' + userName + '</option>');
                } else {
                    alert("提交失败");
                }
            },

            error: function (data) {
                alert("fail");
            }
        });
    }
    function updateStatus(userId, userStatus) {
        $.ajax({
            data: "userId=" + userId + "&userStatus=" + userStatus,
            type: "POST",
            dataType: 'json',
            url: "updateUserStatus.do",
            success: function (data) {
                var input = document.getElementById(data.userId);
                if (data.userStatus == 'Y') {
                    input.setAttribute("value", "禁用");
                } else {
                    input.setAttribute("value", "启用");
                }
            },

            error: function (data) {
                alert("fail");
            }
        });
    }

    function updateUser(id) {
        if (confirm("您确定要修改" + id + "吗?")) {
            console.log(id);
            window.location.href = "${pageContext.request.contextPath}/updateUserPage.do?id=" + id;
        }
    }

    function del(id) {
        if (confirm("您确定要删除吗?")) {
            window.location.href = "${pageContext.request.contextPath}/deleteUser.do?id=" + id;
        }
    }

    $("#checkall").click(function () {
        $("input[name='id[]']").each(function () {
            if (this.checked) {
                this.checked = false;
            } else {
                this.checked = true;
            }
        });
    })

    function DelSelect() {
        var Checkbox = false;
        $("input[name='id[]']").each(function () {
            if (this.checked == true) {
                Checkbox = true;
            }
        });
        if (Checkbox) {
            var t = confirm("您确认要删除选中的内容吗？");
            if (t == false) return false;
        } else {
            alert("请选择您要删除的内容!");
            return false;
        }
    }

</script>
</body>
</html>